/*
 * @Author: zhangzhen
 * @Date: 2022-08-12 08:49:17
 * @LastEditors: zhangzhen
 * @LastEditTime: 2023-04-18 13:17:22
 *
 */
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import viteEslint from 'vite-plugin-eslint'

const path = require('path')

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    react(),
    viteEslint({
      failOnError: false
    })
  ],
  base: './',
  server: {
    // 热更新
    hmr: true,
    // 端口
    port: 8001,
    // 是否开启https服务
    https: false,
    // 代理
    proxy: {
      '/baidu': {
        target: 'https://www.baidu.com',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/baidu/, '')
      },
      '/biying': {
        target: 'https://cn.bing.com',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/biying/, '')
      }
    }
  },
  resolve: {
    //设置路径别名
    alias: {
      '@': path.resolve(__dirname, './src'),
      '*': path.resolve('')
    }
  }
})
